package com.czzn.czkongzhi;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class LightControllActivity extends FunctionActivity{
    private boolean isOffLight1=true,isOffLight2=true,isOffAllLight=true;
    Button light1,light2,light_all;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_light_controll);
        light1= findViewById(R.id.con_light1);
        light2=  findViewById(R.id.con_light2);
        light_all=  findViewById(R.id.all_light);
    }

    public void firstLight(View v){
        if (isOffLight1==true){
                    light1.setBackgroundResource(R.drawable.toggle_on);
                    //sendToBlueTooth("1");
                    isOffLight1=false;
                }else {
                    light1.setBackgroundResource(R.drawable.toggle_off);
                    isOffLight1=true;
                }
    }

    public void secondLight(View v){
        if (isOffLight2==true){
                    light2.setBackgroundResource(R.drawable.toggle_on);
                    isOffLight2=false;
                }else {
                    light2.setBackgroundResource(R.drawable.toggle_off);
                    isOffLight2=true;
                }
    }

    public void allLight(View v){
        if (isOffAllLight==true){
                    light_all.setBackgroundResource(R.drawable.toggle_on);
                    light1.setBackgroundResource(R.drawable.toggle_on);
                    light2.setBackgroundResource(R.drawable.toggle_on);
                    isOffLight1=false;
                    isOffLight2=false;
                    isOffAllLight=false;
                }else {
                    light_all.setBackgroundResource(R.drawable.toggle_off);
                    light1.setBackgroundResource(R.drawable.toggle_off);
                    light2.setBackgroundResource(R.drawable.toggle_off);
                    isOffLight1=true;
                    isOffLight2=true;
                    isOffAllLight=true;
                }
    }

}
